// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   EBookWindow.java

package com.kaylyn.frame;

import com.kaylyn.util.MusicPlayer;
import com.kaylyn.util.Resource;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class EBookWindow extends JFrame
{

    public EBookWindow()
    {
        initialize();
        this.addFocusListener(new FocusListener(){

			@Override
			public void focusGained(FocusEvent e) {
				repaint();
			}

			@Override
			public void focusLost(FocusEvent e) {
				
			}});
    }

    private void initialize()
    {
        java.awt.Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
        setSize(screenDimension);
        setLocation(new Point(0, 0));
        getJPanel();
        setCursor();
        setResizable(false);
        setDefaultCloseOperation(3);
        setUndecorated(true);
        getRootPane().setBorder(BorderFactory.createLineBorder(Color.BLACK));
        setFocusable(true);
        setIconImage(Resource.loadImage("snow.gif"));
        setTitle("For Kaylyn");
        setVisible(true);
        MusicPlayer.start();
    }

    private void getJPanel()
    {
        jPanel = new EBookWindowContentPanel();
        setContentPane(jPanel);
        jPanel.initialize();
        addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e)
            {
                switch(e.getKeyCode())
                {
                case 39: // '\''
                    //jPanel.nextPage(null);
                    break;

                case 37: // '%'
                    //jPanel.lastPageButton.doClick();
                    break;
                }
            }

//            final EBookWindow this$0;
//
//            
//            {
//                this$0 = EBookWindow.this;
//                super();
//            }
        }
);
        generateTitle();
    }

    public void addTitle()
    {
        title.setVisible(true);
    }

    public void removeTitle()
    {
        title.setVisible(false);
    }

    private void generateTitle()
    {
        title = new EBookWindowTitle(this);
        title.setLocation(0, 0);
        title.setSize(880, 25);
        final Point point = new Point();
        title.addMouseListener(new MouseAdapter() {

            public void mousePressed(MouseEvent e)
            {
                point.x = e.getX();
                point.y = e.getY();
            }

//            final EBookWindow this$0;
//            private final Point val$point;
//
//            
//            {
//                this$0 = EBookWindow.this;
//                point = point1;
//                super();
//            }
        }
);
        title.addMouseMotionListener(new MouseMotionAdapter() {

            public void mouseDragged(MouseEvent e)
            {
                Point p = getLocation();
                setLocation((p.x + e.getX()) - point.x, (p.y + e.getY()) - point.y);
                repaint();
            }

//            final EBookWindow this$0;
//            private final Point val$point;
//
//            
//            {
//                this$0 = EBookWindow.this;
//                point = point1;
//                super();
//            }
        }
);
        title.setVisible(false);
        add(title);
    }

    private void setCursor()
    {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        final Cursor cursor[] = new Cursor[5];
        cursor[0] = toolkit.createCustomCursor(Resource.loadImage("cbtrailgif1.gif"), new Point(16, 16), null);
        cursor[1] = toolkit.createCustomCursor(Resource.loadImage("cbtrailgif2.gif"), new Point(16, 16), null);
        cursor[2] = toolkit.createCustomCursor(Resource.loadImage("cbtrailgif3.gif"), new Point(16, 16), null);
        cursor[3] = toolkit.createCustomCursor(Resource.loadImage("cbtrailgif4.gif"), new Point(16, 16), null);
        cursor[4] = toolkit.createCustomCursor(Resource.loadImage("cbtrailgif5.gif"), new Point(16, 16), null);
        javax.swing.Action updateCursorAction = new AbstractAction() {

            public void actionPerformed(ActionEvent e)
            {
                setCursor(cursor[i]);
                i++;
                i %= 5;
            }

            private static final long serialVersionUID = 1L;
            int i;
//            final EBookWindow this$0;
//            private final Cursor val$cursor[];
//
//            
//            {
//                this$0 = EBookWindow.this;
//                cursor = acursor;
//                super();
//                i = 0;
//            }
        }
;
        (new Timer(400, updateCursorAction)).start();
    }

    public static void main(String Args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
    {
    	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        new EBookWindow();
    }

    private static final long serialVersionUID = 1L;
    private EBookWindowContentPanel jPanel;
    private JPanel title;

}
